package com.example.sale24h;



import com.example.forms.frmChonMon;
import com.example.forms.frmPhieuGoiMon;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.Menu;

public class MonanActivity extends FragmentActivity
{

	ViewPager viewPager;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_monan);
		
		viewPager = (ViewPager)findViewById(R.id.viewPager);
		
		MyFragmentAdapter adapter = new MyFragmentAdapter(getSupportFragmentManager());
		viewPager.setAdapter(adapter );
		
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu)
	{
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_monan, menu);
		return true;
	}
	
	private class MyFragmentAdapter extends FragmentPagerAdapter{

		public MyFragmentAdapter(FragmentManager fm) {
			super(fm);
			// TODO Auto-generated constructor stub
		}

		@Override
		public Fragment getItem(int position) {
			// TODO Auto-generated method stub
			switch (position) {
			case 0:				
				return new frmPhieuGoiMon();
			case 1:
				return new frmChonMon();
			
			}
			return null;
		}

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return 2;
		}
		
	}
	

}
